package Entity;

import java.util.*;
import java.io.Serializable;
import Controller.DBcontroller;

/**
 * This is one of the reports.
 * this report is for orders, and it will be produced to the company manager.
 * @author Shahar Shelli
 *
 */
public class OrderReport extends Report implements Serializable
{
	private static final long serialVersionUID = -7959112581326116618L;
	
	private int NumOfOrders;
	private int NumOfSubsOrders;
	private int NumOfInAdvance;
	private Date start;
	private int parkingLot;
	
	/**
	 * is the constructor. it will call the super constructor 
	 * and also set the number of subscriptions orders, number of occational orders and number of orders in advance.
	 * this will be a report for a specific parking lot.
	 * @param s= the start date.
	 * @param e= the end date. e and s will determine the period of time.
	 * @param des= the description for the report.(optional that's why we need this constructor)
	 * @param p= the parking lot number.
	 */
	public OrderReport(Date s,Date e,String des,int p)
	{
		super(e,des);
		this.parkingLot=p;
		this.start=s;
		this.NumOfOrders=DBcontroller.getNumOfOrders(s, e,p);
		this.NumOfSubsOrders=DBcontroller.getNumOfSubsOrders(s, e,p);
		this.NumOfInAdvance=DBcontroller.getNumOfInAdvance(s, e,p);
	}
	
	/**
	 * is the constructor. it will call the super constructor 
	 * and also set the number of subscriptions orders, number of occational orders and number of orders in advance.
	 * this will be a report for a specific parking lot.
	 * @param s= the start date.
	 * @param e= the end date. e and s will determine the period of time.
	 * @param p= the parking lot number.
	 */
	public OrderReport(Date s,Date e,int p)
	{
		super(e,"");
		this.start=s;
		this.NumOfOrders=DBcontroller.getNumOfOrders(s, e,p);
		this.NumOfSubsOrders=DBcontroller.getNumOfSubsOrders(s, e,p);
		this.NumOfInAdvance=DBcontroller.getNumOfInAdvance(s, e,p);
	}
	
	/**
	 * is a function for validate the input. it will only check that the start date is before the end date.
	 * @param s= start date.
	 * @param e= end date.
	 * @param des= the description 
	 * @param p= parking lot number.
	 * @return true or false if everything is ok.
	 */
	public boolean Validate(Date s,Date e,String desc,int p)
	{
		if(s.after(e))
			return false;
		return true;
	}
	
	// the get functions.
	public int getNumOfOrders()
	{
		return this.NumOfOrders;
	}
	
	
	public int getNumOfSubs()
	{
		return this.NumOfSubsOrders;
	}
	
	public int getNumOfInAdvance()
	{
		return this.NumOfInAdvance;
	}
	
	public Date getStart() 
	{
		return start;
	}
	
	public int getParkingLot() {
		return parkingLot;
	}
	
	// the set functions.
	 public void setNumOfInAdvance(int numOfInAdvance) {
		NumOfInAdvance = numOfInAdvance;
	}
	
	 public void setNumOfSubsOrders(int numOfSubsOrders) {
		NumOfSubsOrders = numOfSubsOrders;
	}
	 public void setNumOfOrders(int numOfOrders) {
		NumOfOrders = numOfOrders;
	}

	public static void save(OrderReport r) {
		DBcontroller.saveOrderReport(r);
	}
}
